package minidb.queryexec;
import minidb.parse.sym;
import minidb.parse.exps.*;

public abstract class QueryExecutorBase
{
	
	protected Predicate ExchangePredicate(Predicate p)
	{	
		switch (p.op)
		{
			case sym.IS:
			case sym.ISNOT:
			case sym.LIKE:
			case sym.NOTLIKE:
				return p;
			case sym.EQ:
			case sym.NEQ:
				break;
			case sym.GT:
				p.op = sym.LT;
				break;
			case sym.LE:
				p.op = sym.GE;
				break;
			case sym.GE:
				p.op = sym.LE;
				break;
			case sym.LT:
				p.op = sym.GT;
				break;
		
		}
		Operand temp=p.operand1;
		p.operand1=p.operand2;
		p.operand2=temp;
		return p;
	}
	
	
	protected Boolean GetOpEq(int op)
	{
		switch(op)
		{
			case sym.LE:
			case sym.GE:
				return true;
			case sym.LT:
			case sym.GT:
				return false;
			default:
				return null;
		}
	}
	
	protected Boolean GetOpDirection(int op)
	{
		switch(op)
		{
			case sym.GE:
			case sym.GT:
			case sym.IS:
				return true;
			case sym.LE:
			case sym.LT:
			case sym.ISNOT:
				return false;
			case sym.EQ:
				return null;
			default:
				return null;
		}
	}

}







